package servlet;

import javax.servlet.ServletException;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import java.io.IOException;

public class QueryBookInfoByName_Servlet extends HttpServlet {
    @Override
    protected void doGet(HttpServletRequest req, HttpServletResponse resp) throws ServletException, IOException {
                // 设置 请求和响应的 编码字符为"utf-8"
//                req.setCharacterEncoding("utf-8");
//                resp.setCharacterEncoding("utf-8");
//                String name = req.getParameter("name");
//                BookService bs = new BookService();
//                List<Book> books = bs.QueryBookInfoByName(name);
//                req.setAttribute("book",books);
//                System.out.println(books);
            //如果request域没有数据,使用重定向跳转response.sendRedirect();
            //如果request域有数据 (request.setAttribute()  ),使用请求转发跳转
        req.getRequestDispatcher("main/showbookinfobyname.jsp").forward(req, resp);
    }

    @Override
    protected void doPost(HttpServletRequest req, HttpServletResponse resp) throws ServletException, IOException {
        super.doPost(req, resp);
    }
}
